package com.yufeng.collaboration.controller;

import com.yufeng.collaboration.entity.Comment;
import com.yufeng.collaboration.service.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/comments")
public class CommentController {

    @Autowired
    private CommentService commentService;

    @GetMapping("/{documentId}")
    public List<Comment> getCommentsByDocumentId(@PathVariable Integer documentId) {
        return commentService.getCommentsByDocumentId(documentId);
    }

    @PostMapping
    public void addComment(@RequestBody Comment comment) {
        commentService.addComment(comment);
    }

    @DeleteMapping("/{id}")
    public void deleteComment(@PathVariable Integer id) {
        commentService.deleteComment(id);
    }
}
